<?php 

class Ext_Music_Fetch_Parse_Adapter_Xiami extends Ext_Music_Fetch_Parse_Abstract
{
    public function parse()
    {
        $this->_datas['host'] = "xiami.com";
        $this->_datas['url']  = $this->_url;

        if(preg_match("/song\/([0-9]+)/ui", $this->_url, $m) && $m[1])
        {      
            $xiamiMusicId = $m[1];
            $this->_datas['viewId']     = $xiamiMusicId;
        }

        if(preg_match("/<div id=\"title\">[^>]*?<h1>([^>]*?)<\/h1>/ui", $this->_html, $m) && $m[1])
        {
             $this->_datas['name'] = $m[1];
        }
        
        if(preg_match("/演唱者：<\/td>[^>]*?<td valign=\"top\"><a [^>]*?>([^>]*?)<\/a>/ui", $this->_html, $m) && $m[1])
        {
             $this->_datas['singer'] = $m[1];
        }
        
        if(preg_match("/<div id=\"title\">[^>]*?<h1>([^>]*?)<\/h1>[^>]*?<\/div>/ui", $this->_html, $m) && $m[1])
        {
             $this->_datas['description'] = $m[1];
        }elseif(preg_match("/<div id=\"title\">[^>]*?<h1>(.*?)<\/h1>[^>]*?<\/div>/ui", $this->_html, $m) && $m[1])
        {
             $this->_datas['description'] = strip_tags($m[1]);
        }

        if(preg_match("/<img class=\"cdCDcover185\" src=\"(http:\/\/img.xiami.com\/[^>]*?)\" \/>/usi", $this->_html, $m) && $m[1])
        {
             $this->_datas['photo']= $m[1];
        }
    }

}
